<%@page import="util.enviaEmail"%>
<%
Connection conn = null;
try {
	conn = new Conexao().getConexao();
} catch (Exception e) {
	new enviaEmail().enviar(e);
	out.print("falhaConexao");
	return;
}
%>
<%@page import="conexao.Conexao"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="dao.OSDao"%>
<%@page import="bean.OSBean"%>
<%@page import="dao.funcionarioDao"%>
<%@page import="bean.funcionarioBean"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="js/jquery.arrasta.js"></script>
<link rel="stylesheet" href="css/blue/style.css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<legend class="ui-corner-all" style="font-size: 14px;">Designers</legend>
	<br/>
	<div id="divDesigners">
		<%
			funcionarioBean func = new funcionarioBean();
			func.setIdEmpresa((Integer) session.getAttribute("idempresa"));
			List<funcionarioBean> funcionarios = new funcionarioDao()
					.getListaDesigner(conn, func);
			if (!funcionarios.isEmpty()) {
				for (int i = 0; i < funcionarios.size(); i++) {
		%>
		<fieldset id="designers" class="ui-corner-top"
			style="padding-top: 10px; padding-bottom: 10px; padding-left: 0px; padding-right: 0px; margin-top: 6px;">
			<legend class="ui-corner-all"
				style="margin-left: 10px;"><%=funcionarios.get(i).getNome()%></legend>
			<table class="tablesorter ui-corner-top" id="<%=funcionarios.get(i).getId()%>">
				<thead>
					<tr>
						<th width="25" class="ui-corner-tl">Cód.</th>
						<th>Cliente</th>
						<th align="center" width="85">Entrada</th>
						<th align="center" width="35">Ações</th>
						<th width="6" class="ui-corner-tr"></th>
					</tr>
				</thead>
			</table>
			<div id="<%=funcionarios.get(i).getId()%>" class="divScroll">
			<table class="tablesorter">
				<tbody>
					<%
						List<OSBean> designerOS = new OSDao().getListaOS(conn,
										"('designer', 'voltouDesigner')", funcionarios.get(i).getId());
								if (!designerOS.isEmpty()) {
									for (int n = 0; n < designerOS.size(); n++) {
										SimpleDateFormat df = new SimpleDateFormat(
												"dd/MM/yyyy HH:mm");
										String data = df.format(designerOS.get(n)
												.getDataDesigner());
					%>
					<tr id="<%=designerOS.get(n).getId()%>"
					<%if(designerOS.get(n).getUrgente() == 1){%>
					style="color: red;"
					<%}%>
					>
						<td width="27"><%=designerOS.get(n).getId()%></td>
						<td><%=designerOS.get(n).getNomeCliente()%></td>
						<td align="center" width="87"><%=data%></td>
						<td width="37" align="center"><img onclick="abreDescricao('<%=designerOS.get(n).getId()%>')" src="imagens/magnifier-zoom.png" title="Descrição e Comentário" style="cursor: pointer;">
							<img src="imagens/imprimir.png" title="Imprimir" style="cursor: pointer;" onclick="imprimirOS('<%=designerOS.get(n).getId()%>')">
						</td>
					</tr>
					<%
						}
								} else {
					%>
					<tr>
						<td colspan="3">Nenhuma OS enviada</td>
					</tr>
					<%
						}
					%>
				</tbody>
			</table>
			</div>
		</fieldset>

		<%
			}
			} else {
		%>
		<br/>
		Nenhum Designer Cadastrado
		<%
			}
			conn.close();
		%>
	</div>
</body>
</html>